home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / amiga / gcc233.lha / info / libg++.info-4 < prev    next >
Text File  |  1992-07-19  |  51KB  |  1,526 lines

  1. Info file libg++.info, produced by Makeinfo, -*- Text -*- from input
  2. file libg++.texinfo.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Libg++: (libg++).        The g++ library.
  6. END-INFO-DIR-ENTRY
  7.  
  8.    This file documents the features and implementation of The GNU C++
  9. library
  10.  
  11.    Copyright (C) 1988, 1991, 1992 Free Software Foundation, Inc.
  12.  
  13.    Permission is granted to make and distribute verbatim copies of
  14. this manual provided the copyright notice and this permission notice
  15. are preserved on all copies.
  16.  
  17.    Permission is granted to copy and distribute modified versions of
  18. this manual under the conditions for verbatim copying, provided also
  19. that the section entitled "GNU Library General Public License" is
  20. included exactly as in the original, and provided that the entire
  21. resulting derived work is distributed under the terms of a permission
  22. notice identical to this one.
  23.  
  24.    Permission is granted to copy and distribute translations of this
  25. manual into another language, under the above conditions for modified
  26. versions, except that the section entitled "GNU Library General Public
  27. License" and this permission notice may be included in translations
  28. approved by the Free Software Foundation instead of in the original
  29. English.
  30.  
  31. 
  32. File: libg++.info,  Node: Random,  Next: Data,  Prev: Bit,  Up: Top
  33.  
  34. Random Number Generators and related classes
  35. ********************************************
  36.  
  37.    The two classes `RNG' and `Random' are used together to generate a
  38. variety of random number distributions.  A distinction must be made
  39. between *random number generators*, implemented by class `RNG', and
  40. *random number distributions*.  A random number generator produces a
  41. series of randomly ordered bits.  These bits can be used directly, or
  42. cast to other representations, such as a floating point value.  A
  43. random number generator should produce a *uniform* distribution.  A
  44. random number distribution, on the other hand, uses the randomly
  45. generated bits of a generator to produce numbers from a distribution
  46. with specific properties.  Each instance of `Random' uses an instance
  47. of class `RNG' to provide the raw, uniform distribution used to
  48. produce the specific distribution.  Several instances of `Random'
  49. classes can share the same instance of `RNG', or each instance can use
  50. its own copy.
  51.  
  52. RNG
  53. ===
  54.  
  55.    Random distributions are constructed from members of class `RNG',
  56. the actual random number generators.  The `RNG' class contains no
  57. data; it only serves to define the interface to random number
  58. generators.  The `RNG::asLong' member returns an unsigned long
  59. (typically 32 bits) of random bits.  Applications that require a number
  60. of random bits can use this directly.  More often, these random bits
  61. are transformed to a uniform random number:
  62.  
  63.          //
  64.          // Return random bits converted to either a float or a double
  65.          //
  66.          float asFloat();
  67.          double asDouble();
  68.      };
  69.  
  70. using either `asFloat' or `asDouble'.  It is intended that `asFloat'
  71. and `asDouble' return differing precisions; typically, `asDouble' will
  72. draw two random longwords and transform them into a legal `double',
  73. while `asFloat' will draw a single longword and transform it into a
  74. legal `float'.  These members are used by subclasses of the `Random'
  75. class to implement a variety of random number distributions.
  76.  
  77. ACG
  78. ===
  79.  
  80.    Class `ACG' is a variant of a Linear Congruential Generator
  81. (Algorithm M) described in Knuth, *Art of Computer Programming, Vol
  82. III*.  This result is permuted with a Fibonacci Additive Congruential
  83. Generator to get good independence between samples.  This is a very
  84. high quality random number generator, although it requires a fair
  85. amount of memory for each instance of the generator.
  86.  
  87.    The `ACG::ACG' constructor takes two parameters: the seed and the
  88. size.  The seed is any number to be used as an initial seed. The
  89. performance of the generator depends on having a distribution of bits
  90. through the seed.  If you choose a number in the range of 0 to 31, a
  91. seed with more bits is chosen. Other values are deterministically
  92. modified to give a better distribution of bits.  This provides a good
  93. random number generator while still allowing a sequence to be repeated
  94. given the same initial seed.
  95.  
  96.    The `size' parameter determines the size of two tables used in the
  97. generator. The first table is used in the Additive Generator; see the
  98. algorithm in Knuth for more information. In general, this table is
  99. `size' longwords long. The default value, used in the algorithm in
  100. Knuth, gives a table of 220 bytes. The table size affects the period of
  101. the generators; smaller values give shorter periods and larger tables
  102. give longer periods. The smallest table size is 7 longwords, and the
  103. longest is 98 longwords. The `size' parameter also determines the size
  104. of the table used for the Linear Congruential Generator. This value is
  105. chosen implicitly based on the size of the Additive Congruential
  106. Generator table. It is two powers of two larger than the power of two
  107. that is larger than `size'.  For example, if `size' is 7, the ACG
  108. table is 7 longwords and the LCG table is 128 longwords. Thus, the
  109. default size (55) requires 55 + 256 longwords, or 1244 bytes. The
  110. largest table requires 2440 bytes and the smallest table requires 100
  111. bytes.  Applications that require a large number of generators or
  112. applications that aren't so fussy about the quality of the generator
  113. may elect to use the `MLCG' generator.
  114.  
  115. MLCG
  116. ====
  117.  
  118.    The `MLCG' class implements a *Multiplicative Linear Congruential
  119. Generator*. In particular, it is an implementation of the double MLCG
  120. described in *"Efficient and Portable Combined Random Number
  121. Generators"* by Pierre L'Ecuyer, appearing in *Communications of the
  122. ACM, Vol. 31. No. 6*. This generator has a fairly long period, and has
  123. been statistically analyzed to show that it gives good inter-sample
  124. independence.
  125.  
  126.    The `MLCG::MLCG' constructor has two parameters, both of which are
  127. seeds for the generator. As in the `MLCG' generator, both seeds are
  128. modified to give a "better" distribution of seed digits. Thus, you can
  129. safely use values such as `0' or `1' for the seeds. The `MLCG'
  130. generator used much less state than the `ACG' generator; only two
  131. longwords (8 bytes) are needed for each generator.
  132.  
  133. Random
  134. ======
  135.  
  136.    A random number generator may be declared by first declaring a
  137. `RNG' and then a `Random'. For example, `ACG gen(10, 20);
  138. NegativeExpntl rnd (1.0, &gen);' declares an additive congruential
  139. generator with seed 10 and table size 20, that is used to generate
  140. exponentially distributed values with mean of 1.0.
  141.  
  142.    The virtual member `Random::operator()' is the common way of
  143. extracting a random number from a particular distribution.  The base
  144. class, `Random' does not implement `operator()'. This is performed by
  145. each of the subclasses. Thus, given the above declaration of `rnd',
  146. new random values may be obtained via, for example, `double
  147. next_exp_rand = rnd();' Currently, the following subclasses are
  148. provided.
  149.  
  150. Binomial
  151. ========
  152.  
  153.    The binomial distribution models successfully drawing items from a
  154. pool.  The first parameter to the constructor, `n', is the number of
  155. items in the pool, and the second parameter, `u', is the probability
  156. of each item being successfully drawn.  The member `asDouble' returns
  157. the number of samples drawn from the pool.  Although it is not
  158. checked, it is assumed that `n>0' and `0 <= u <= 1'.  The remaining
  159. members allow you to read and set the parameters.
  160.  
  161. Erlang
  162. ======
  163.  
  164.    The `Erlang' class implements an Erlang distribution with mean
  165. `mean' and variance `variance'.
  166.  
  167. Geometric
  168. =========
  169.  
  170.    The `Geometric' class implements a discrete geometric distribution.
  171.  The first parameter to the constructor, `mean', is the mean of the
  172. distribution.  Although it is not checked, it is assumed that `0 <=
  173. mean <= 1'.  `Geometric()' returns the number of uniform random samples
  174. that were drawn before the sample was larger than `mean'.  This
  175. quantity is always greater than zero.
  176.  
  177. HyperGeometric
  178. ==============
  179.  
  180.    The `HyperGeometric' class implements the hypergeometric
  181. distribution.  The first parameter to the constructor, `mean', is the
  182. mean and the second, `variance', is the variance.  The remaining
  183. members allow you to inspect and change the mean and variance.
  184.  
  185. NegativeExpntl
  186. ==============
  187.  
  188.    The `NegativeExpntl' class implements the negative exponential
  189. distribution.  The first parameter to the constructor is the mean. 
  190. The remaining members allow you to inspect and change the mean.
  191.  
  192. Normal
  193. ======
  194.  
  195.    The `Normal'class implements the normal distribution.  The first
  196. parameter to the constructor, `mean', is the mean and the second,
  197. `variance', is the variance.  The remaining members allow you to
  198. inspect and change the mean and variance.  The `LogNormal' class is a
  199. subclass of `Normal'.
  200.  
  201. LogNormal
  202. =========
  203.  
  204.    The `LogNormal'class implements the logarithmic normal
  205. distribution.  The first parameter to the constructor, `mean', is the
  206. mean and the second, `variance', is the variance.  The remaining
  207. members allow you to inspect and change the mean and variance.  The
  208. `LogNormal' class is a subclass of `Normal'.
  209.  
  210. Poisson
  211. =======
  212.  
  213.    The `Poisson' class implements the poisson distribution.  The first
  214. parameter to the constructor is the mean.  The remaining members allow
  215. you to inspect and change the mean.
  216.  
  217. DiscreteUniform
  218. ===============
  219.  
  220.    The `DiscreteUniform' class implements a uniform random variable
  221. over the closed interval ranging from `[low..high]'.  The first
  222. parameter to the constructor is `low', and the second is `high',
  223. although the order of these may be reversed.  The remaining members
  224. allow you to inspect and change `low' and `high'.
  225.  
  226. Uniform
  227. =======
  228.  
  229.    The `Uniform' class implements a uniform random variable over the
  230. open interval ranging from `[low..high)'.  The first parameter to the
  231. constructor is `low', and the second is `high', although the order of
  232. these may be reversed.  The remaining members allow you to inspect and
  233. change `low' and `high'.
  234.  
  235. Weibull
  236. =======
  237.  
  238.    The `Weibull' class implements a weibull distribution with
  239. parameters `alpha' and `beta'.  The first parameter to the class
  240. constructor is `alpha', and the second parameter is `beta'.  The
  241. remaining members allow you to inspect and change `alpha' and `beta'.
  242.  
  243. RandomInteger
  244. =============
  245.  
  246.    The `RandomInteger' class is *not* a subclass of Random, but a
  247. stand-alone integer-oriented class that is dependent on the RNG
  248. classes. RandomInteger returns random integers uniformly from the
  249. closed interval `[low..high]'.  The first parameter to the constructor
  250. is `low', and the second is `high', although both are optional.  The
  251. last argument is always a generator.  Additional members allow you to
  252. inspect and change `low' and `high'.  Random integers are generated
  253. using `asInt()' or `asLong()'.  Operator syntax (`()') is also
  254. available as a shorthand for `asLong()'.  Because `RandomInteger' is
  255. often used in simulations for which uniform random integers are
  256. desired over a variety of ranges, `asLong()' and `asInt' have `high'
  257. as an optional argument.  Using this optional argument produces a
  258. single value from the new range, but does not change the default range.
  259.  
  260. 
  261. File: libg++.info,  Node: Data,  Next: Curses,  Prev: Random,  Up: Top
  262.  
  263. Data Collection
  264. ***************
  265.  
  266.    Libg++ currently provides two classes for *data collection* and
  267. analysis of the collected data.
  268.  
  269. SampleStatistic
  270. ===============
  271.  
  272.    Class `SampleStatistic' provides a means of accumulating samples of
  273. `double' values and providing common sample statistics.
  274.  
  275.    Assume declaration of `double x'.
  276.  
  277. `SampleStatistic a;'
  278.      declares and initializes a.
  279.  
  280. `a.reset();'
  281.      re-initializes a.
  282.  
  283. `a += x;'
  284.      adds sample x.
  285.  
  286. `int n = a.samples();'
  287.      returns the number of samples.
  288.  
  289. `x = a.mean;'
  290.      returns the means of the samples.
  291.  
  292. `x = a.var()'
  293.      returns the sample variance of the samples.
  294.  
  295. `x = a.stdDev()'
  296.      returns the sample standard deviation of the samples.
  297.  
  298. `x = a.min()'
  299.      returns the minimum encountered sample.
  300.  
  301. `x = a.max()'
  302.      returns the maximum encountered sample.
  303.  
  304. `x = a.confidence(int p)'
  305.      returns the p-percent (0 <= p < 100) confidence interval.
  306.  
  307. `x = a.confidence(double p)'
  308.      returns the p-probability (0 <= p < 1) confidence interval.
  309.  
  310. SampleHistogram
  311. ===============
  312.  
  313.    Class `SampleHistogram' is a derived class of `SampleStatistic'
  314. that supports collection and display of samples in bucketed intervals.
  315. It supports the following in addition to `SampleStatisic' operations.
  316.  
  317. `SampleHistogram h(double lo, double hi, double width);'
  318.      declares and initializes h to have buckets of size width from lo
  319.      to hi.  If the optional argument width is not specified, 10
  320.      buckets are created. The first bucket and also holds samples less
  321.      than lo, and the last one holds samples greater than hi.
  322.  
  323. `int n = h.similarSamples(x)'
  324.      returns the number of samples in the same bucket as x.
  325.  
  326. `int n = h.inBucket(int i)'
  327.      returns the number of samples in  bucket i.
  328.  
  329. `int b = h.buckets()'
  330.      returns the number of buckets.
  331.  
  332. `h.printBuckets(ostream s)'
  333.      prints bucket counts on ostream s.
  334.  
  335. `double bound = h.bucketThreshold(int i)'
  336.      returns the upper bound of bucket i.
  337.  
  338. 
  339. File: libg++.info,  Node: Curses,  Next: List,  Prev: Data,  Up: Top
  340.  
  341. Curses-based classes
  342. ********************
  343.  
  344.    The `CursesWindow' class is a repackaging of standard curses
  345. library features into a class. It relies on `curses.h'.
  346.  
  347.    The supplied `curses.h' is a fairly conservative declaration of
  348. curses library features, and does not include features like "screen"
  349. or X-window support. It is, for the most part, an adaptation, rather
  350. than an improvement of C-based `curses.h' files. The only substantive
  351. changes are the declarations of many functions as inline functions
  352. rather than macros, which was done solely to allow overloading.
  353.  
  354.    The `CursesWindow' class encapsulates curses window functions
  355. within a class. Only those functions that control windows are included:
  356. Terminal control functions and macros like `cbreak' are not part of
  357. the class.  All `CursesWindows' member functions have names identical
  358. to the corresponding curses library functions, except that the "w"
  359. prefix is generally dropped. Descriptions of these functions may be
  360. found in your local curses library documentation.
  361.  
  362.    A `CursesWindow' may be declared via
  363.  
  364. `CursesWindow w(WINDOW* win)'
  365.      attaches w to the existing WINDOW* win. This is constructor is
  366.      normally used only in the following special case.
  367.  
  368. `CursesWindow w(stdscr)'
  369.      attaches w to the default curses library standard screen window.
  370.  
  371. `CursesWindow w(int lines, int cols, int begin_y, int begin_x)'
  372.      attaches to an allocated curses window with the indicated size and
  373.      screen position.
  374.  
  375. `CursesWindow sub(CursesWindow& w,int l,int c,int by,int bx,char ar='a')'
  376.      attaches to a subwindow of w created via the curses `subwin'
  377.      command.  If ar is sent as `r', the origin (by, bx) is relative
  378.      to the parent window, else it is absolute.
  379.  
  380.    The class maintains a static counter that is used in order to
  381. automatically call the curses library `initscr' and `endscr' functions
  382. at the proper times. These need not, and should not be called
  383. "manually".
  384.  
  385.    `CursesWindow's maintain a tree of their subwindows. Upon
  386. destruction of a `CursesWindow', all of their subwindows are also
  387. invalidated if they had not previously been destroyed.
  388.  
  389.    It is possible to traverse trees of subwindows via the following
  390. member functions
  391.  
  392. `CursesWindow* w.parent()'
  393.      returns a pointer to the parent of the subwindow, or 0 if there
  394.      is none.
  395.  
  396. `CursesWindow* w.child()'
  397.      returns the first child subwindow of the window, or 0 if there is
  398.      none.
  399.  
  400. `CursesWindow* w.sibling()'
  401.      returns the next sibling of the subwindow, or 0 if there is none.
  402.  
  403.    For example, to call some function `visit' for all subwindows of a
  404. window, you could write
  405.  
  406.  
  407.      void traverse(CursesWindow& w)
  408.      {
  409.        visit(w);
  410.        if (w.child() != 0) traverse(*w.child);
  411.        if (w.sibling() != 0) traverse(*w.sibling);
  412.      }
  413.  
  414. 
  415. File: libg++.info,  Node: List,  Next: LinkList,  Prev: Curses,  Up: Top
  416.  
  417. List classes
  418. ************
  419.  
  420.    The files `g++-include/List.hP' and `g++-include/List.ccP' provide
  421. pseudo-generic Lisp-type List classes.  These lists are homogeneous
  422. lists, more similar to lists in statically typed functional languages
  423. like ML than Lisp, but support operations very similar to those found
  424. in Lisp.  Any particular kind of list class may be generated via the
  425. `genclass' shell command. However, the implementation assumes that the
  426. base class supports an equality operator `=='.  All equality tests use
  427. the `==' operator, and are thus equivalent to the use of `equal', not
  428. `eq' in Lisp.
  429.  
  430.    All list nodes are created dynamically, and managed via reference
  431. counts.  `List' variables are actually pointers to these list nodes. 
  432. Lists may also be traversed via Pixes, as described in the section
  433. describing Pixes. *Note Pix::
  434.  
  435.    Supported operations are mirrored closely after those in Lisp.
  436. Generally, operations with functional forms are constructive,
  437. functional operations, while member forms (often with the same name)
  438. are sometimes procedural, possibly destructive operations.
  439.  
  440.    As with Lisp, destructive operations are supported. Programmers are
  441. allowed to change head and tail fields in any fashion, creating
  442. circular structures and the like. However, again as with Lisp, some
  443. operations implicitly assume that they are operating on pure lists, and
  444. may enter infinite loops when presented with improper lists. Also, the
  445. reference-counting storage management facility may fail to reclaim
  446. unused circularly-linked nodes.
  447.  
  448.    Several Lisp-like higher order functions are supported (e.g.,
  449. `map').  Typedef declarations for the required functional forms are
  450. provided int the `.h' file.
  451.  
  452.    For purposes of illustration, assume the specification of class
  453. `intList'.  Common Lisp versions of supported operations are shown in
  454. brackets for comparison purposes.
  455.  
  456. Constructors and assignment
  457. ===========================
  458.  
  459. `intList a;           [ (setq a nil) ]'
  460.      Declares a to be a nil intList.
  461.  
  462. `intList b(2);        [ (setq b (cons 2 nil)) ]'
  463.      Declares b to be an intList with a head value of 2, and a nil
  464.      tail.
  465.  
  466. `intList c(3, b);     [ (setq c (cons 3 b)) ]'
  467.      Declares c to be an intList with a head value of 3, and b as its
  468.      tail.
  469.  
  470. `b = a;               [ (setq b a) ]'
  471.      Sets b to be the same list as a.
  472.  
  473.    Assume the declarations of intLists a, b, and c in the following. 
  474. *Note Pix::.
  475.  
  476. List status
  477. ===========
  478.  
  479. `a.null(); OR !a;      [ (null a) ]'
  480.      returns true if a is null.
  481.  
  482. `a.valid();            [ (listp a) ]'
  483.      returns true if a is non-null. Inside a conditional test, the
  484.      `void*' coercion may also be used as in `if (a) ...'.
  485.  
  486. `intList();            [ nil ]'
  487.      intList() may be used to null terminate a list, as in `intList
  488.      f(int x) {if (x == 0) return intList(); ... } '.
  489.  
  490. `a.length();           [ (length a) ]'
  491.      returns the length of a.
  492.  
  493. `a.list_length();      [ (list-length a) ]'
  494.      returns the length of a, or -1 if a is circular.
  495.  
  496. heads and tails
  497. ===============
  498.  
  499. `a.get(); OR a.head()  [ (car a) ]'
  500.      returns a reference to the head field.
  501.  
  502. `a[2];                 [ (elt a 2) ]'
  503.      returns a reference to the second (counting from zero) head field.
  504.  
  505. `a.tail();             [ (cdr a) ]'
  506.      returns the intList that is the tail of a.
  507.  
  508. `a.last();             [ (last a) ]'
  509.      returns the intList that is the last node of a.
  510.  
  511. `a.nth(2);             [ (nth a 2) ]'
  512.      returns the intList that is the nth node of a.
  513.  
  514. `a.set_tail(b);        [ (rplacd a b) ]'
  515.      sets a's tail to b.
  516.  
  517. `a.push(2);            [ (push 2 a) ]'
  518.      equivalent to a = intList(2, a);
  519.  
  520. `int x = a.pop()       [ (setq x (car a)) (pop a) ]'
  521.      returns the head of a, also setting a to its tail.
  522.  
  523. Constructive operations
  524. =======================
  525.  
  526. `b = copy(a);          [ (setq b (copy-seq a)) ]'
  527.      sets b to a copy of a.
  528.  
  529. `b = reverse(a);       [ (setq b (reverse a)) ]'
  530.      Sets b to a reversed copy of a.
  531.  
  532. `c = concat(a, b);     [ (setq c (concat a b)) ]'
  533.      Sets c to a concatenated copy of a and b.
  534.  
  535. `c = append(a, b);     [ (setq c (append a b)) ]'
  536.      Sets c to a concatenated copy of a and b. All nodes of a are
  537.      copied, with the last node pointing to b.
  538.  
  539. `b = map(f, a);        [ (setq b (mapcar f a)) ]'
  540.      Sets b to a new list created by applying function f to each node
  541.      of a.
  542.  
  543. `c = combine(f, a, b);'
  544.      Sets c to a new list created by applying function f to successive
  545.      pairs of a and b. The resulting list has length the shorter of a
  546.      and b.
  547.  
  548. `b = remove(x, a);     [ (setq b (remove x a)) ]'
  549.      Sets b to a copy of a, omitting all occurrences of x.
  550.  
  551. `b = remove(f, a);     [ (setq b (remove-if f a)) ]'
  552.      Sets b to a copy of a, omitting values causing function f to
  553.      return true.
  554.  
  555. `b = select(f, a);     [ (setq b (remove-if-not f a)) ]'
  556.      Sets b to a copy of a, omitting values causing function f to
  557.      return false.
  558.  
  559. `c = merge(a, b, f);   [ (setq c (merge a b f)) ]'
  560.      Sets c to a list containing the ordered elements (using the
  561.      comparison function f) of the sorted lists a and b.
  562.  
  563. Destructive operations
  564. ======================
  565.  
  566. `a.append(b);          [ (rplacd (last a) b) ]'
  567.      appends b to the end of a. No new nodes are constructed.
  568.  
  569. `a.prepend(b);         [ (setq a (append b a)) ]'
  570.      prepends b to the beginning of a.
  571.  
  572. `a.del(x);             [ (delete x a) ]'
  573.      deletes all nodes with value x from a.
  574.  
  575. `a.del(f);             [ (delete-if f a) ]'
  576.      deletes all nodes causing function f to return true.
  577.  
  578. `a.select(f);          [ (delete-if-not f a) ]'
  579.      deletes all nodes causing function f to return false.
  580.  
  581. `a.reverse();          [ (nreverse a) ]'
  582.      reverses a in-place.
  583.  
  584. `a.sort(f);            [ (sort a f) ]'
  585.      sorts a in-place using ordering (comparison) function f.
  586.  
  587. `a.apply(f);           [ (mapc f a) ]'
  588.      Applies void function f (int x) to each element of a.
  589.  
  590. `a.subst(int old, int repl); [ (nsubst repl old a) ]'
  591.      substitutes repl for each occurrence of old in a. Note the
  592.      different argument order than the Lisp version.
  593.  
  594. Other operations
  595. ================
  596.  
  597. `a.find(int x);       [ (find x a) ]'
  598.      returns the intList at the first occurrence of x.
  599.  
  600. `a.find(b);           [ (find b a) ]'
  601.      returns the intList at the first occurrence of sublist b.
  602.  
  603. `a.contains(int x);    [ (member x a) ]'
  604.      returns true if a contains x.
  605.  
  606. `a.contains(b);        [ (member b a) ]'
  607.      returns true if a contains sublist b.
  608.  
  609. `a.position(int x);    [ (position x a) ]'
  610.      returns the zero-based index of x in a, or -1 if x does not occur.
  611.  
  612. `int x = a.reduce(f, int base); [ (reduce f a :initial-value base) ]'
  613.      Accumulates the result of applying int function f(int, int) to
  614.      successive elements of a, starting with base.
  615.  
  616. 
  617. File: libg++.info,  Node: LinkList,  Next: Vector,  Prev: List,  Up: Top
  618.  
  619. Linked Lists
  620. ************
  621.  
  622.    SLLists provide pseudo-generic singly linked lists.  DLLists provide
  623. doubly linked lists.  The lists are designed for the simple maintenance
  624. of elements in a linked structure, and do not provide the more
  625. extensive operations (or node-sharing) of class `List'. They behave
  626. similarly to the `slist' and similar classes described by Stroustrup.
  627.  
  628.    All list nodes are created dynamically. Assignment is performed via
  629. copying.
  630.  
  631.    Class `DLList' supports all `SLList' operations, plus additional
  632. operations described below.
  633.  
  634.    For purposes of illustration, assume the specification of class
  635. `intSLList'. In addition to the operations listed here, SLLists
  636. support traversal via Pixes. *Note Pix::
  637.  
  638. `intSLList a;'
  639.      Declares a to be an empty list.
  640.  
  641. `intSLList b = a;'
  642.      Sets b to an element-by-element copy of a.
  643.  
  644. `a.empty()'
  645.      returns true if a contains no elements
  646.  
  647. `a.length();'
  648.      returns the number of elements in a.
  649.  
  650. `a.prepend(x);'
  651.      places x at the front of the list.
  652.  
  653. `a.append(x);'
  654.      places x at the end of the list.
  655.  
  656. `a.join(b)'
  657.      places all nodes from b to the end of a, simultaneously
  658.      destroying b.
  659.  
  660. `x = a.front()'
  661.      returns a reference to the item stored at the head of the list,
  662.      or triggers an error if the list is empty.
  663.  
  664. `a.rear()'
  665.      returns a reference to the rear of the list, or triggers an error
  666.      if the list is empty.
  667.  
  668. `x = a.remove_front()'
  669.      deletes and returns the item stored at the head of the list.
  670.  
  671. `a.del_front()'
  672.      deletes the first element, without returning it.
  673.  
  674. `a.clear()'
  675.      deletes all items from the list.
  676.  
  677. `a.ins_after(Pix i, item);'
  678.      inserts item after position i. If i is null, insertion is at the
  679.      front.
  680.  
  681. `a.del_after(Pix i);'
  682.      deletes the element following i. If i is 0, the first item is
  683.      deleted.
  684.  
  685. Doubly linked lists
  686. ===================
  687.  
  688.    Class `DLList' supports the following additional operations, as
  689. well as backward traversal via Pixes.
  690.  
  691. `x = a.remove_rear();'
  692.      deletes and returns the item stored at the rear of the list.
  693.  
  694. `a.del_rear();'
  695.      deletes the last element, without returning it.
  696.  
  697. `a.ins_before(Pix i, x)'
  698.      inserts x before the i.
  699.  
  700. `a.del(Pix& iint dir = 1)'
  701.      deletes the item at the current position, then advances forward
  702.      if dir is positive, else backward.
  703.  
  704. 
  705. File: libg++.info,  Node: Vector,  Next: Plex,  Prev: LinkList,  Up: Top
  706.  
  707. Vector classes
  708. **************
  709.  
  710.    The files `g++-include/Vec.ccP' and `g++-include/AVec.ccP' provide
  711. pseudo-generic standard array-based vector operations.  The
  712. corresponding header files are `g++-include/Vec.hP' and
  713. `g++-include/AVec.hP'.  Class `Vec' provides operations suitable for
  714. any base class that includes an equality operator. Subclass `AVec'
  715. provides additional arithmetic operations suitable for base classes
  716. that include the full complement of arithmetic operators.
  717.  
  718.    `Vecs' are constructed and assigned by copying. Thus, they should
  719. normally be passed by reference in applications programs.
  720.  
  721.    Several mapping functions are provided that allow programmers to
  722. specify operations on vectors as a whole.
  723.  
  724.    For illustrative purposes assume that classes `intVec' and
  725. `intAVec' have been generated via `genclass'.
  726.  
  727. Constructors and assignment
  728. ===========================
  729.  
  730. `intVec a;'
  731.      declares a to be an empty vector. Its size may be changed via
  732.      resize.
  733.  
  734. `intVec a(10);'
  735.      declares a to be an uninitialized vector of ten elements
  736.      (numbered 0-9).
  737.  
  738. `intVec b(6, 0);'
  739.      declares b to be a vector of six elements, all initialized to
  740.      zero. Any value can be used as the initial fill argument.
  741.  
  742. `a = b;'
  743.      Copies b to a. a is resized to be the same as b.
  744.  
  745. `a = b.at(2, 4)'
  746.      constructs a from the 4 elements of b starting at b[2].
  747.  
  748.    Assume declarations of `intVec a, b, c' and `int i, x' in the
  749. following.
  750.  
  751. Status and access
  752. =================
  753.  
  754. `a.capacity();'
  755.      returns the number of elements that can be held in a.
  756.  
  757. `a.resize(20);'
  758.      sets a's length to 20. All elements are unchanged, except that if
  759.      the new size is smaller than the original, than trailing elements
  760.      are deleted, and if greater, trailing elements are uninitialized.
  761.  
  762. `a[i];'
  763.      returns a reference to the i'th element of a, or produces an error
  764.      if i is out of range.
  765.  
  766. `a.elem(i)'
  767.      returns a reference to the i'th element of a. Unlike the `[]'
  768.      operator, i is not checked to ensure that it is within range.
  769.  
  770. `a == b;'
  771.      returns true if a and b contain the same elements in the same
  772.      order.
  773.  
  774. `a != b;'
  775.      is the converse of a == b.
  776.  
  777. Constructive operations
  778. =======================
  779.  
  780. `c = concat(a, b);'
  781.      sets c to the new vector constructed from all of the elements of
  782.      a followed by all of b.
  783.  
  784. `c = map(f, a);'
  785.      sets c to the new vector constructed by applying int function
  786.      f(int) to each element of a.
  787.  
  788. `c = merge(a, b, f);'
  789.      sets c to the new vector constructed by merging the elements of
  790.      ordered vectors a and b using ordering (comparison) function f.
  791.  
  792. `c = combine(f, a, b);'
  793.      sets c to the new vector constructed by applying int function
  794.      f(int, int) to successive pairs of a and b. The result has length
  795.      the shorter of a and b.
  796.  
  797. `c = reverse(a)'
  798.      sets c to a, with elements in reverse order.
  799.  
  800. Destructive operations
  801. ======================
  802.  
  803. `a.reverse();'
  804.      reverses a in-place.
  805.  
  806. `a.sort(f)'
  807.      sorts a in-place using comparison function f. The sorting method
  808.      is a variation of the quicksort functions supplied with GNU emacs.
  809.  
  810. `a.fill(0, 4, 2)'
  811.      fills the 2 elements starting at a[4] with zero.
  812.  
  813. Other operations
  814. ================
  815.  
  816. `a.apply(f)'
  817.      applies function f to each element in a.
  818.  
  819. `x = a.reduce(f, base)'
  820.      accumulates the results of applying function f to successive
  821.      elements of a starting with base.
  822.  
  823. `a.index(int targ);'
  824.      returns the index of the leftmost occurrence of the target, or -1,
  825.      if it does not occur.
  826.  
  827. `a.error(char* msg)'
  828.      invokes the error handler. The default version prints the error
  829.      message, then aborts.
  830.  
  831. AVec operations.
  832. ================
  833.  
  834.    AVecs provide additional arithmetic operations.  All
  835. vector-by-vector operators generate an error if the vectors are not
  836. the same length. The following operations are provided, for `AVecs a,
  837. b' and base element (scalar) `s'.
  838.  
  839. `a = b;'
  840.      Copies b to a. a and b must be the same size.
  841.  
  842. `a = s;'
  843.      fills all elements of a with the value s. a is not resized.
  844.  
  845. `a + s; a - s; a * s; a / s'
  846.      adds, subtracts, multiplies, or divides each element of a with
  847.      the scalar.
  848.  
  849. `a += s; a -= s; a *= s; a /= s;'
  850.      adds, subtracts, multiplies, or divides the scalar into a.
  851.  
  852. `a + b; a - b; product(a, b), quotient(a, b)'
  853.      adds, subtracts, multiplies, or divides corresponding elements of
  854.      a and b.
  855.  
  856. `a += b; a -= b; a.product(b); a.quotient(b);'
  857.      adds, subtracts, multiplies, or divides corresponding elements of
  858.      b into a.
  859.  
  860. `s = a * b;'
  861.      returns the inner (dot) product of a and b.
  862.  
  863. `x = a.sum();'
  864.      returns the sum of elements of a.
  865.  
  866. `x = a.sumsq();'
  867.      returns the sum of squared elements of a.
  868.  
  869. `x = a.min();'
  870.      returns the minimum element of a.
  871.  
  872. `x = a.max();'
  873.      returns the maximum element of a.
  874.  
  875. `i = a.min_index();'
  876.      returns the index of the minimum element of a.
  877.  
  878. `i = a.max_index();'
  879.      returns the index of the maximum element of a.
  880.  
  881.      Note that it is possible to apply vector versions other arithmetic
  882.      operators via the mapping functions. For example, to set vector b
  883.      to the  cosines of doubleVec a, use `b = map(cos, a);'.  This is
  884.      often more efficient than performing the operations in an
  885.      element-by-element fashion.
  886.  
  887. 
  888. File: libg++.info,  Node: Plex,  Next: Stack,  Prev: Vector,  Up: Top
  889.  
  890. Plex classes
  891. ************
  892.  
  893.    A "Plex" is a kind of array with the following properties:
  894.  
  895.    * Plexes may have arbitrary upper and lower index bounds. For
  896.      example a Plex may be declared to run from indices -10 .. 10.
  897.  
  898.    * Plexes may be dynamically expanded at both the lower and upper
  899.      bounds of the array in steps of one element.
  900.  
  901.    * Only elements that have been specifically initialized or added may
  902.      be accessed.
  903.  
  904.    * Elements may be accessed via indices. Indices are always checked
  905.      for validity at run time.  Plexes may be traversed via simple
  906.      variations of standard array indexing loops.
  907.  
  908.    * Plex elements may be accessed and traversed via Pixes.
  909.  
  910.    * Plex-to-Plex assignment and related operations on entire Plexes
  911.      are supported.
  912.  
  913.    * Plex classes contain methods to help programmers check the
  914.      validity of indexing and pointer operations.
  915.  
  916.    * Plexes form "natural" base classes for many restricted-access data
  917.      structures relying on logically contiguous indices, such as
  918.      array-based stacks and queues.
  919.  
  920.    * Plexes are implemented as pseudo-generic classes, and must be
  921.      generated via the `genclass' utility.
  922.  
  923.    Four subclasses of Plexes are supported: A `FPlex' is a Plex that
  924. may only grow or shrink within declared bounds; an `XPlex' may
  925. dynamically grow or shrink without bounds; an `RPlex' is the same as
  926. an `XPlex' but better supports indexing with poor locality of
  927. reference; a `MPlex' may grow or shrink, and additionally allows the
  928. logical deletion and restoration of elements. Because these classes
  929. are virtual subclasses of the "abstract" class `Plex', it is possible
  930. to write user code such as `void f(Plex& a) ...' that operates on any
  931. kind of Plex. However, as with nearly any virtual class, specifying the
  932. particular Plex class being used results in more efficient code.
  933.  
  934.    Plexes are implemented as a linked list of `IChunks'.  Each chunk
  935. contains a part of the array. Chunk sizes may be specified within Plex
  936. constructors.  Default versions also exist, that use a `#define'd'
  937. default.  Plexes grow by filling unused space in existing chunks, if
  938. possible, else, except for FPlexes, by adding another chunk.  Whenever
  939. Plexes grow by a new chunk, the default element constructors (i.e.,
  940. those which take no arguments) for all chunk elements are called at
  941. once. When Plexes shrink, destructors for the elements are not called
  942. until an entire chunk is freed. For this reason, Plexes (like C++
  943. arrays) should only be used for elements with default constructors and
  944. destructors that have no side effects.
  945.  
  946.    Plexes may be indexed and used like arrays, although traversal
  947. syntax is slightly different. Even though Plexes maintain elements in
  948. lists of chunks, they are implemented so that iteration and other
  949. constructs that maintain locality of reference require very little
  950. overhead over that for simple array traversal Pix-based traversal is
  951. also supported. For example, for a plex, p, of ints, the following
  952. traversal methods could be used.
  953.  
  954.      for (int i = p.low(); i < p.fence(); p.next(i)) use(p[i]);
  955.      for (int i = p.high(); i > p.ecnef(); p.prev(i)) use(p[i]);
  956.      for (Pix t = p.first(); t != 0; p.next(t)) use(p(i));
  957.      for (Pix t = p.last(); t != 0; p.prev(t)) use(p(i));
  958.  
  959.    Except for MPlexes, simply using `++i' and `--i' works just as well
  960. as `p.next(i)' and `p.prev(i)' when traversing by index.  Index-based
  961. traversal is generally a bit faster than Pix-based traversal.
  962.  
  963.    `XPlexes' and `MPlexes' are less than optimal for applications in
  964. which widely scattered elements are indexed, as might occur when using
  965. Plexes as hash tables or "manually" allocated linked lists.  In such
  966. applications, `RPlexes' are often preferable. `RPlexes' use a
  967. secondary chunk index table that requires slightly greater, but
  968. entirely uniform overhead per index operation.
  969.  
  970.    Even though they may grow in either direction, Plexes are normally
  971. constructed so that their "natural" growth direction is upwards, in
  972. that default chunk construction leaves free space, if present, at the
  973. end of the plex. However, if the chunksize arguments to constructors
  974. are negative, they leave space at the beginning.
  975.  
  976.    All versions of Plexes support the following basic capabilities. 
  977. (letting `Plex' stand for the type name constructed via the genclass
  978. utility (e.g., `intPlex', `doublePlex')).  Assume declarations of
  979. `Plex p, q', `int i, j', base element `x', and Pix `pix'.
  980.  
  981. `Plex p;'
  982.      Declares p to be an initially zero-sized Plex with low index of
  983.      zero, and the default chunk size. For FPlexes, chunk sizes
  984.      represent maximum sizes.
  985.  
  986. `Plex p(int size);'
  987.      Declares p to be an initially zero-sized Plex with low index of
  988.      zero, and the indicated chunk size. If size is negative, then the
  989.      Plex is created with free space at the beginning of the Plex,
  990.      allowing more efficient add_low() operations. Otherwise, it
  991.      leaves space at the end.
  992.  
  993. `Plex p(int low, int size);'
  994.      Declares p to be an initially zero-sized Plex with low index of
  995.      low, and the indicated chunk size.
  996.  
  997. `Plex p(int low, int high, Base initval, int size = 0);'
  998.      Declares p to be a Plex with indices from low to high, initially
  999.      filled with initval, and the indicated chunk size if specified,
  1000.      else the default or (high - low + 1), whichever is greater.
  1001.  
  1002. `Plex q(p);'
  1003.      Declares q to be a copy of p.
  1004.  
  1005. `p = q;'
  1006.      Copies Plex q into p, deleting its previous contents.
  1007.  
  1008. `p.length()'
  1009.      Returns the number of elements in the Plex.
  1010.  
  1011. `p.empty()'
  1012.      Returns true if Plex p contains no elements.
  1013.  
  1014. `p.full()'
  1015.      Returns true if Plex p cannot be expanded. This always returns
  1016.      false for XPlexes and MPlexes.
  1017.  
  1018. `p[i]'
  1019.      Returns a reference to the i'th element of p. An exception
  1020.      (error) occurs if i is not a valid index.
  1021.  
  1022. `p.valid(i)'
  1023.      Returns true if i is a valid index into Plex p.
  1024.  
  1025. `p.low(); p.high();'
  1026.      Return the minimum (maximum) valid index of the Plex, or the high
  1027.      (low) fence if the plex is empty.
  1028.  
  1029. `p.ecnef(); p.fence();'
  1030.      Return the index one position past the minimum (maximum) valid
  1031.      index.
  1032.  
  1033. `p.next(i); i = p.prev(i);'
  1034.      Set i to the next (previous) index. This index may not be within
  1035.      bounds.
  1036.  
  1037. `p(pix)'
  1038.      returns a reference to the item at Pix pix.
  1039.  
  1040. `pix = p.first(); pix = p.last();'
  1041.      Return the minimum (maximum) valid Pix of the Plex, or 0 if the
  1042.      plex is empty.
  1043.  
  1044. `p.next(pix); p.prev(pix);'
  1045.      set pix to the next (previous) Pix, or 0 if there is none.
  1046.  
  1047. `p.owns(pix)'
  1048.      Returns true if the Plex contains the element associated with pix.
  1049.  
  1050. `p.Pix_to_index(pix)'
  1051.      If pix is a valid Pix to an element of the Plex, returns its
  1052.      corresponding index, else raises an exception.
  1053.  
  1054. `ptr = p.index_to_Pix(i)'
  1055.      if i is a valid index, returns a the corresponding Pix.
  1056.  
  1057. `p.low_element(); p.high_element();'
  1058.      Return a reference to the element at the minimum (maximum) valid
  1059.      index.  An exception occurs if the Plex is empty.
  1060.  
  1061. `p.can_add_low();  p.can_add_high();'
  1062.      Returns true if the plex can be extended one element downward
  1063.      (upward).  These always return true for XPlex and MPlex.
  1064.  
  1065. `j = p.add_low(x); j = p.add_high(x);'
  1066.      Extend the Plex by one element downward (upward). The new minimum
  1067.      (maximum) index is returned.
  1068.  
  1069. `j = p.del_low(); j = p.del_high()'
  1070.      Shrink the Plex by one element on the low (high) end. The new
  1071.      minimum (maximum) element is returned. An exception occurs if the
  1072.      Plex is empty.
  1073.  
  1074. `p.append(q);'
  1075.      Append all of Plex q to the high side of p.
  1076.  
  1077. `p.prepend(q);'
  1078.      Prepend all of q to the low side of p.
  1079.  
  1080. `p.clear()'
  1081.      Delete all elements, resetting p to a zero-sized Plex.
  1082.  
  1083. `p.reset_low(i);'
  1084.      Resets p to be indexed starting at low() = i. For example.  if p
  1085.      were initially declared via `Plex p(0, 10, 0)', and then
  1086.      re-indexed via `p.reset_low(5)', it could then be indexed from
  1087.      indices 5 .. 14.
  1088.  
  1089. `p.fill(x)'
  1090.      sets all p[i] to x.
  1091.  
  1092. `p.fill(x, lo, hi)'
  1093.      sets all of p[i] from lo to hi, inclusive, to x.
  1094.  
  1095. `p.reverse()'
  1096.      reverses p in-place.
  1097.  
  1098. `p.chunk_size()'
  1099.      returns the chunk size used for the plex.
  1100.  
  1101. `p.error(const char * msg)'
  1102.      calls the resettable error handler.
  1103.  
  1104.    MPlexes are plexes with bitmaps that allow items to be logically
  1105. deleted and restored. They behave like other plexes, but also support
  1106. the following additional and modified capabilities:
  1107.  
  1108. `p.del_index(i); p.del_Pix(pix)'
  1109.      logically deletes p[i] (p(pix)). After deletion, attempts to
  1110.      access p[i] generate a error. Indexing via low(), high(), prev(),
  1111.      and next() skip the element. Deleting an element never changes the
  1112.      logical bounds of the plex.
  1113.  
  1114. `p.undel_index(i); p.undel_Pix(pix)'
  1115.      logically undeletes p[i] (p(pix)).
  1116.  
  1117. `p.del_low(); p.del_high()'
  1118.      Delete the lowest (highest) undeleted element, resetting the
  1119.      logical bounds of the plex to the next lowest (highest) undeleted
  1120.      index. Thus, MPlex del_low() and del_high() may shrink the bounds
  1121.      of the plex by more than one index.
  1122.  
  1123. `p.adjust_bounds()'
  1124.      Resets the low and high bounds of the Plex to the indexes of the
  1125.      lowest and highest actual undeleted elements.
  1126.  
  1127. `int i = p.add(x)'
  1128.      Adds x in an unused index, if possible, else performs add_high.
  1129.  
  1130. `p.count()'
  1131.      returns the number of valid (undeleted) elements.
  1132.  
  1133. `p.available()'
  1134.      returns the number of available (deleted) indices.
  1135.  
  1136. `int i = p.unused_index()'
  1137.      returns the index of some deleted element, if one exists, else
  1138.      triggers an error. An unused element may be reused via undel.
  1139.  
  1140. `pix = p.unused_Pix()'
  1141.      returns the pix of some deleted element, if one exists, else 0. 
  1142.      An unused element may be reused via undel.
  1143.  
  1144. 
  1145. File: libg++.info,  Node: Stack,  Next: Queue,  Prev: Plex,  Up: Top
  1146.  
  1147. Stacks
  1148. ******
  1149.  
  1150.    Stacks are declared as an "abstract" class. They are currently
  1151. implemented in any of three ways.
  1152.  
  1153. `VStack'
  1154.      implement fixed sized stacks via arrays.
  1155.  
  1156. `XPStack'
  1157.      implement dynamically-sized stacks via XPlexes.
  1158.  
  1159. `SLStack'
  1160.      implement dynamically-size stacks via linked lists.
  1161.  
  1162.    All possess the same capabilities. They differ only in constructors. 
  1163. VStack constructors require a fixed maximum capacity argument. 
  1164. XPStack constructors optionally take a chunk size argument.  SLStack
  1165. constructors take no argument.
  1166.  
  1167.    Assume the declaration of a base element `x'.
  1168.  
  1169. `Stack s;  or Stack s(int capacity)'
  1170.      declares a Stack.
  1171.  
  1172. `s.empty()'
  1173.      returns true if stack s is empty.
  1174.  
  1175. `s.full()'
  1176.      returns true if stack s is full. XPStacks and SLStacks never
  1177.      become full.
  1178.  
  1179. `s.length()'
  1180.      returns the current number of elements in the stack.
  1181.  
  1182. `s.push(x)'
  1183.      pushes x on stack s.
  1184.  
  1185. `x = s.pop()'
  1186.      pops and returns the top of stack
  1187.  
  1188. `s.top()'
  1189.      returns a reference to the top of stack.
  1190.  
  1191. `s.del_top()'
  1192.      pops, but does not return the top of stack. When large items are
  1193.      held on the stack it is often a good idea to use `top()' to
  1194.      inspect and use the top of stack, followed by a `del_top()'
  1195.  
  1196. `s.clear()'
  1197.      removes all elements from the stack.
  1198.  
  1199. 
  1200. File: libg++.info,  Node: Queue,  Next: Deque,  Prev: Stack,  Up: Top
  1201.  
  1202. Queues
  1203. ******
  1204.  
  1205.    Queues are declared as an "abstract" class. They are currently
  1206. implemented in any of three ways.
  1207.  
  1208. `VQueue'
  1209.      implement fixed sized Queues via arrays.
  1210.  
  1211. `XPQueue'
  1212.      implement dynamically-sized Queues via XPlexes.
  1213.  
  1214. `SLQueue'
  1215.      implement dynamically-size Queues via linked lists.
  1216.  
  1217.    All possess the same capabilities; they differ only in constructors. 
  1218. `VQueue' constructors require a fixed maximum capacity argument. 
  1219. `XPQueue' constructors optionally take a chunk size argument. 
  1220. `SLQueue' constructors take no argument.
  1221.  
  1222.    Assume the declaration of a base element `x'.
  1223.  
  1224. `Queue q; or Queue q(int capacity);'
  1225.      declares a queue.
  1226.  
  1227. `q.empty()'
  1228.      returns true if queue q is empty.
  1229.  
  1230. `q.full()'
  1231.      returns true if queue q is full. XPQueues and SLQueues are never
  1232.      full.
  1233.  
  1234. `q.length()'
  1235.      returns the current number of elements in the queue.
  1236.  
  1237. `q.enq(x)'
  1238.      enqueues x on queue q.
  1239.  
  1240. `x = q.deq()'
  1241.      dequeues and returns the front of queue
  1242.  
  1243. `q.front()'
  1244.      returns a reference to the front of queue.
  1245.  
  1246. `q.del_front()'
  1247.      dequeues, but does not return the front of queue
  1248.  
  1249. `q.clear()'
  1250.      removes all elements from the queue.
  1251.  
  1252. 
  1253. File: libg++.info,  Node: Deque,  Next: PQ,  Prev: Queue,  Up: Top
  1254.  
  1255. Double ended Queues
  1256. *******************
  1257.  
  1258.    Deques are declared as an "abstract" class. They are currently
  1259. implemented in two ways.
  1260.  
  1261. `XPDeque'
  1262.      implement dynamically-sized Deques via XPlexes.
  1263.  
  1264. `DLDeque'
  1265.      implement dynamically-size Deques via linked lists.
  1266.  
  1267.    All possess the same capabilities. They differ only in constructors. 
  1268. XPDeque constructors optionally take a chunk size argument.  DLDeque
  1269. constructors take no argument.
  1270.  
  1271.    Double-ended queues support both stack-like and queue-like
  1272. capabilities:
  1273.  
  1274.    Assume the declaration of a base element `x'.
  1275.  
  1276. `Deque d; or Deque d(int initial_capacity)'
  1277.      declares a deque.
  1278.  
  1279. `d.empty()'
  1280.      returns true if deque d is empty.
  1281.  
  1282. `d.full()'
  1283.      returns true if deque d is full.  Always returns false in current
  1284.      implementations.
  1285.  
  1286. `d.length()'
  1287.      returns the current number of elements in the deque.
  1288.  
  1289. `d.enq(x)'
  1290.      inserts x at the rear of deque d.
  1291.  
  1292. `d.push(x)'
  1293.      inserts x at the front of deque d.
  1294.  
  1295. `x = d.deq()'
  1296.      dequeues and returns the front of deque
  1297.  
  1298. `d.front()'
  1299.      returns a reference to the front of deque.
  1300.  
  1301. `d.rear()'
  1302.      returns a reference to the rear of the deque.
  1303.  
  1304. `d.del_front()'
  1305.      deletes, but does not return the front of deque
  1306.  
  1307. `d.del_rear()'
  1308.      deletes, but does not return the rear of the deque.
  1309.  
  1310. `d.clear()'
  1311.      removes all elements from the deque.
  1312.  
  1313. 
  1314. File: libg++.info,  Node: PQ,  Next: Set,  Prev: Deque,  Up: Top
  1315.  
  1316. Priority Queue class prototypes.
  1317. ********************************
  1318.  
  1319.    Priority queues maintain collections of objects arranged for fast
  1320. access to the least element.
  1321.  
  1322.    Several prototype implementations of priority queues are supported.
  1323.  
  1324. `XPPQs'
  1325.      implement 2-ary heaps via XPlexes.
  1326.  
  1327. `SplayPQs'
  1328.      implement  PQs via Sleater and Tarjan's (JACM 1985) splay trees.
  1329.      The algorithms use a version of "simple top-down splaying"
  1330.      (described on page 669 of the article).  The simple-splay
  1331.      mechanism for priority queue functions is loosely based on the
  1332.      one used by D. Jones in the C splay tree functions available from
  1333.      volume 14 of the uunet.uu.net archives.
  1334.  
  1335. `PHPQs'
  1336.      implement pairing heaps (as described by Fredman and Sedgewick in
  1337.      `Algorithmica', Vol 1, p111-129).  Storage for heap elements is
  1338.      managed via an internal freelist technique. The constructor
  1339.      allows an initial capacity estimate for freelist space.  The
  1340.      storage is automatically expanded if necessary to hold new items.
  1341.      The deletion technique is a fast "lazy deletion" strategy that
  1342.      marks items as deleted, without reclaiming space until the items
  1343.      come to the top of the heap.
  1344.  
  1345.    All PQ classes support the following operations, for some PQ class
  1346. `Heap', instance `h', `Pix ind', and base class variable `x'.
  1347.  
  1348. `h.empty()'
  1349.      returns true if there are no elements in the PQ.
  1350.  
  1351. `h.length()'
  1352.      returns the number of elements in h.
  1353.  
  1354. `ind = h.enq(x)'
  1355.      Places x in the PQ, and returns its index.
  1356.  
  1357. `x = h.deq()'
  1358.      Dequeues the minimum element of the PQ into x, or generates an
  1359.      error if the PQ is empty.
  1360.  
  1361. `h.front()'
  1362.      returns a reference to the minimum element.
  1363.  
  1364. `h.del_front()'
  1365.      deletes the minimum element.
  1366.  
  1367. `h.clear();'
  1368.      deletes all elements from h;
  1369.  
  1370. `h.contains(x)'
  1371.      returns true if x is in h.
  1372.  
  1373. `h(ind)'
  1374.      returns a reference to the item indexed by ind.
  1375.  
  1376. `ind = h.first()'
  1377.      returns the Pix of first item in the PQ or 0 if empty.  This need
  1378.      not be the Pix of the least element.
  1379.  
  1380. `h.next(ind)'
  1381.      advances ind to the Pix of next element, or 0 if there are no
  1382.      more.
  1383.  
  1384. `ind = h.seek(x)'
  1385.      Sets ind to the Pix of x, or 0 if x is not in h.
  1386.  
  1387. `h.del(ind)'
  1388.      deletes the item with Pix ind.
  1389.  
  1390. 
  1391. File: libg++.info,  Node: Set,  Next: Bag,  Prev: PQ,  Up: Top
  1392.  
  1393. Set class prototypes
  1394. ********************
  1395.  
  1396.    Set classes maintain unbounded collections of items containing no
  1397. duplicate elements.
  1398.  
  1399.    These are currently implemented in several ways, differing in
  1400. representation strategy, algorithmic efficiency, and appropriateness
  1401. for various tasks. (Listed next to each are average (followed by
  1402. worst-case, if different) time complexities for [a] adding, [f]
  1403. finding (via seek, contains), [d] deleting, elements, and [c]
  1404. comparing (via ==, <=) and [m] merging (via |=, -=, &=) sets).
  1405.  
  1406. `XPSets'
  1407.      implement unordered sets via XPlexes.  ([a O(n)], [f O(n)], [d
  1408.      O(n)], [c O(n^2)] [m O(n^2)]).
  1409.  
  1410. `OXPSets'
  1411.      implement ordered sets via XPlexes.  ([a O(n)], [f O(log n)], [d
  1412.      O(n)], [c O(n)] [m O(n)]).
  1413.  
  1414. `SLSets'
  1415.      implement unordered sets via linked lists ([a O(n)], [f O(n)], [d
  1416.      O(n)], [c O(n^2)] [m O(n^2)]).
  1417.  
  1418. `OSLSets'
  1419.      implement ordered sets via linked lists ([a O(n)], [f O(n)], [d
  1420.      O(n)], [c O(n)] [m O(n)]).
  1421.  
  1422. `AVLSets'
  1423.      implement ordered sets via threaded AVL trees ([a O(log n)], [f
  1424.      O(log n)], [d O(log n)], [c O(n)] [m O(n)]).
  1425.  
  1426. `BSTSets'
  1427.      implement ordered sets via binary search trees. The trees may be
  1428.      manually rebalanced via the O(n) `balance()' member function. 
  1429.      ([a O(log n)/O(n)], [f O(log n)/O(n)], [d O(log n)/O(n)], [c
  1430.      O(n)] [m O(n)]).
  1431.  
  1432. `SplaySets'
  1433.      implement ordered sets via Sleater and Tarjan's (JACM 1985) splay
  1434.      trees. The algorithms use a version of "simple top-down splaying"
  1435.      (described on page 669 of the article).  (Amortized: [a O(log
  1436.      n)], [f O(log n)], [d O(log n)], [c O(n)] [m O(n log n)]).
  1437.  
  1438. `VHSets'
  1439.      implement unordered sets via hash tables.  The tables are
  1440.      automatically resized when their capacity is exhausted.  ([a
  1441.      O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m
  1442.      O(n)/O(n^2)]).
  1443.  
  1444. `VOHSets'
  1445.      implement unordered sets via ordered hash tables The tables are
  1446.      automatically resized when their capacity is exhausted.  ([a
  1447.      O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m
  1448.      O(n)/O(n^2)]).
  1449.  
  1450. `CHSets'
  1451.      implement unordered sets via chained hash tables.  ([a
  1452.      O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m
  1453.      O(n)/O(n^2)]).
  1454.  
  1455.    The different implementations differ in whether their constructors
  1456. require an argument specifying their initial capacity. Initial
  1457. capacities are required for plex and hash table based Sets.  If none is
  1458. given `DEFAULT_INITIAL_CAPACITY' (from `<T>defs.h') is used.
  1459.  
  1460.    Sets support the following operations, for some class `Set',
  1461. instances `a' and `b', `Pix ind', and base element `x'. Since all
  1462. implementations are virtual derived classes of the `<T>Set' class, it
  1463. is possible to mix and match operations across different
  1464. implementations, although, as usual, operations are generally faster
  1465. when the particular classes are specified in functions operating on
  1466. Sets.
  1467.  
  1468.    Pix-based operations are more fully described in the section on
  1469. Pixes. *Note Pix::
  1470.  
  1471. `Set a; or Set a(int initial_size);'
  1472.      Declares a to be an empty Set. The second version is allowed in
  1473.      set classes that require initial capacity or sizing
  1474.      specifications.
  1475.  
  1476. `a.empty()'
  1477.      returns true if a is empty.
  1478.  
  1479. `a.length()'
  1480.      returns the number of elements in a.
  1481.  
  1482. `Pix ind = a.add(x)'
  1483.      inserts x into a, returning its index.
  1484.  
  1485. `a.del(x)'
  1486.      deletes x from a.
  1487.  
  1488. `a.clear()'
  1489.      deletes all elements from a;
  1490.  
  1491. `a.contains(x)'
  1492.      returns true if x is in a.
  1493.  
  1494. `a(ind)'
  1495.      returns a reference to the item indexed by ind.
  1496.  
  1497. `ind = a.first()'
  1498.      returns the Pix of first item in the set or 0 if the Set is empty. 
  1499.      For ordered Sets, this is the Pix of the least element.
  1500.  
  1501. `a.next(ind)'
  1502.      advances ind to the Pix of next element, or 0 if there are no
  1503.      more.
  1504.  
  1505. `ind = a.seek(x)'
  1506.      Sets ind to the Pix of x, or 0 if x is not in a.
  1507.  
  1508. `a == b'
  1509.      returns true if a and b contain all the same elements.
  1510.  
  1511. `a != b'
  1512.      returns true if a and b do not contain all the same elements.
  1513.  
  1514. `a <= b'
  1515.      returns true if a is a subset of b.
  1516.  
  1517. `a |= b'
  1518.      Adds all elements of b to a.
  1519.  
  1520. `a -= b'
  1521.      Deletes all elements of b from a.
  1522.  
  1523. `a &= b'
  1524.      Deletes all elements of a not occurring in b.
  1525.  
  1526.